<?php

namespace app\admin\validate;
use think\Validate;

class Goods extends Validate
{
    protected $rule = [
        'name'              => 'require',
        'good_sn'           => 'require|unique:goods',
        'shop_price'        => 'require|float',
        'market_price'      => 'require|float',
        'supp_price'        => 'require|float',
        'give_integral'     => 'require|number',
        'give_growth'       => 'require|number',
        'stock'             => 'require|number',
        'supp_price'        => 'lt:shop_price',
        //辅助消息
        'img'               => 'require',
        // 'content'           => 'chsAlphaNum',
        'cate_id'            => 'gt:0',
        'supplier_id'       => 'gt:0',
    ];

    protected $message = [
        'name.require'              => '商品名称不能为空',
        'good_sn.require'           => '商品编号不能为空',
        'good_sn.unique'            => '商品编号已存在',
        'shop_price.require'        => '售价不能为空',
        'shop_price.float'          => '售价必须为数字',
        'market_price.require'      => '市场价不能为空',
        'market_price.float'        => '市场价必须为数字',
        'supp_price.lt'             => '供货价不能高于售价哟',
        'supp_price.require'        => '供货价不能为空',
        'supp_price.float'          => '供货价必须为数字',
        'give_integral.require'     => '赠送积分不能为空',
        'give_integral.number'      => '赠送积分必须为数字',
        'give_growth.require'       => '赠送成长值不能为空',
        'give_growth.number'        => '赠送成长值必须为数字',
        'stock.require'             => '库存不能为空',
        'stock.number'              => '库存必须为数字',
        'img.require'               => '缩略图不能为空',
        // 'content.chsAlphaNum'       => '商品详情不能有特殊字符',
        'cate_id.gt'                 => '请选择商品分类',
        'supplier_id.gt'            => '请选择供应商',
    ];
}
